package com.taobao.ued.toy.service;


import com.taobao.ued.toy.dao.DesignerDao;
import com.taobao.ued.toy.dao.FollowRelationDao;
import com.taobao.ued.toy.dao.PicDao;
import com.taobao.ued.toy.dao.WorkDao;
import com.taobao.ued.toy.domain.Designer;
import com.taobao.ued.toy.domain.FollowRelation;
import com.taobao.ued.toy.domain.Pic;
import com.taobao.ued.toy.domain.Work;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SimpleToyManager implements ToyManager {
	@Autowired
	private DesignerDao designerDao;

	@Autowired
	private PicDao picDao;

	@Autowired
	private FollowRelationDao followRelationDao;

	@Autowired
	private WorkDao workDao;


	public List<Work> getCoverWorksByDesigner(String designerId) {
		return workDao.getCoversByDesigner(designerId);
	}

	public int getWorksByDesignerCount(String designerId) {
		return workDao.getsByDesignerCount(designerId);
	}

	public List<Work> getWorksByDesigner(String id, int start, int end) throws Exception {
		return workDao.getsByDesigner(id, start, end);
	}

	public void addPic(Pic p) throws Exception {
		picDao.add(p);
	}

	public List<Pic> getPicsByWork(int id) throws Exception {
		return picDao.getsByWork(id);
	}

	public int addWork(Work w) throws Exception {
		return workDao.add(w);
	}


	public Designer getDesignerByDomain(String domain) throws Exception {
		return designerDao.getByDomain(domain);
	}

	public void updateDesigner(Designer d) throws Exception {
		designerDao.update(d);
	}

	public void addDesigner(Designer d) throws Exception {
		designerDao.add(d);
	}

	public Designer getDesigner(String id) throws Exception {
		return designerDao.get(id);
	}

	public List<Designer> getFollowers(String followingId, int start, int end) throws Exception {
		return followRelationDao.getFollowers(followingId, start, end);
	}

	public int getFollowersCount(String followingId) throws Exception {
		return followRelationDao.getFollowersCount(followingId);
	}

	public int getFollowingsCount(String designerId) throws Exception {
		return followRelationDao.getFollowingsCount(designerId);
	}

	public List<Designer> getFollowings(String followingId, int start, int end) throws Exception {
		return followRelationDao.getFollowings(followingId, start, end);
	}


	public void addFollowRelation(FollowRelation d) throws Exception {
		followRelationDao.add(d);
	}

	public void deleteFollowRelation(FollowRelation d) throws Exception {
		followRelationDao.delete(d);
	}

	public void acknowledgement(FollowRelation d) throws Exception {
		followRelationDao.acknowledgement(d);
	}

	public List<Designer> getNotAckFollowers(String followingId, int start, int end) throws Exception {
		return followRelationDao.getNotAckFollowers(followingId, start, end);
	}


	public int getNotAckFollowersCount(String followingId) throws Exception {
		return followRelationDao.getNotAckFollowersCount(followingId);
	}

}
